SRC	=	src/kmain.c		\
		src/bochs.c		\
		src/assert.c		\
		src/display.c		\
		src/ioports.c

OBJ	=	$(SRC:.c=.o)

CC      =       i586-elf-gcc

LD      =       i586-elf-ld

CFLAGS  +=      -I./include/ -Wall -fstrength-reduce            \
                -fomit-frame-pointer -nostdinc -fno-builtin     \
                -Wstrict-prototypes -DASSERT

NAME	=	floppy.img

all	:	$(NAME)

$(NAME) :	boot.bin kern.bin floppy

floppy	:	boot.bin kern.bin
		cat build/boot.bin build/kern.bin > build/floppy.img

kern.elf:	$(OBJ)
		nasm -f elf -o src/kentry.o src/kentry.asm
		$(LD) -T tools/kernel.lds -o build/kern.elf src/kentry.o $(OBJ)

boot.bin:	kern.elf
		nasm -f bin -o build/boot.bin boot/boot.asm

kern.bin: 	kern.elf
		objcopy -v -O binary -R .bootsect build/kern.elf build/kern.bin

clean	:
		rm -f *~
		rm -f *.o
		rm -f \#*\#
		rm -f src/*~
		rm -f src/*.o
		rm -f src/\#*\#
		rm -f boot/*~
		rm -f boot/*.o
		rm -f boot/\#*\#

fclean	: 	clean
		rm -f build/*.bin
		rm -f build/*.elf

re	: 	fclean all
